// pages/ebook/description/catalog/catalog.js
var app=getApp();
var num;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    checkbox:[],
    lists:[],
    memory:'',
    selAddress:'',
    item:[],
    name:" "
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.data.name = options.name;
    console.log("memory is"+options.memory);
    this.setData({
      num: options.num,
    });
    num = options.num;
    console.log(options.num);
    var { lists } = this.data;
    console.log(app.globalData.arr);
    for (var i=0;i<=num;i++)
    {
      var t = i+1;
      var newData = { text: "第" + t + "章", url: "http://localhost:8088/JYSystem/static/plugins/pdfjs/web/viewer.html?" + "num=" + num + "&file=/JYSystem/upload/file/"+this.data.name+".pdf" + "&#page=" + app.globalData.arr[i] };
      lists.push(newData);
      this.setData({
        lists: lists
      }) 
    }

  },
  jumptobook: function (e) {
    var that = this;
    var data = e.currentTarget.dataset.url;
    console.log(data);
    if (data)
    {
      wx.navigateTo({
        url: "book?data=" + encodeURIComponent(data)
      })
    }
    else{
      data = "http://localhost:8088/JYSystem/static/plugins/pdfjs/web/viewer.html?"+"num="+num+"&file=/JYSystem/upload/file/"+that.data.name+".pdf";
      wx.navigateTo({
        url: "book?data=" + encodeURIComponent(data)
      })
    }


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})